<template>
	<section>
		<div id='collectList'>
			<el-tabs v-model="activeName" type="card" @tab-click="handleClick">
				<el-tab-pane label="低价" name="0"><warnlist0/></el-tab-pane>
				<el-tab-pane label="假货" name="1"><warnlist1/></el-tab-pane>
				<el-tab-pane label="非授权商家" name="2"><warnlist2/></el-tab-pane>
			</el-tabs>
		</div>
	</section>
</template>
<script>
    import Vue from 'vue'
    import {mapGetters} from 'vuex'
    import { ACTIVE_NAME } from '../../store/mutation-types/warning/index.js'
    import { ACTIVE_NAME_H } from '../../store/mutation-types/warning/index.js'
    import { ACTIVE_NAME_FAKE } from '../../store/mutation-types/warning/index.js'
    import { ACTIVE_NAME_FAKE_H } from '../../store/mutation-types/warning/index.js'
    import { ACTIVE_NAME_RPT } from '../../store/mutation-types/warning/index.js'
    import { ACTIVE_NAME_RPT_H } from '../../store/mutation-types/warning/index.js'
    import {Button, Tabs, TabPane, TableColumn, Form, Table, FormItem, Option, Select, Input,Pagination} from 'element-ui'
    import warnlist0 from '~/components/warning/collect-warn/warnList0.vue'
    import warnlist1 from '~/components/warning/collect-warn/warnList1.vue'
    import warnlist2 from '~/components/warning/collect-warn/warnList2.vue'

    Vue.use(Tabs)
    Vue.use(Button)
    Vue.use(Select)
    Vue.use(Input)
    Vue.use(TabPane)
    Vue.use(Form)
    Vue.use(Option)
    Vue.use(FormItem)
    Vue.use(TableColumn)
    Vue.use(Table)
    Vue.use(Pagination)
    export default {
        head(){
            return {

            }
        },
        data() {
            return {
                today:'',
                tab:'',
                activeName:'0',
            }
        },
        computed: {
            ...mapGetters({
                'pageTabsList': 'getPageTabsList',
//             'activeName' : 'getLowPrice'
            })
        },
        mounted() {
        	this.getURL()
        	let url = window.location.href;
		    url = url.substring(url.lastIndexOf("="));
		    let getTab = url.charAt(1);
        	if(this.today==1){
        		if(getTab==0){
        			this.activeName=this.$store.state.warning.activeName;
		        	if(this.activeName == ''){
		        	  this.changeTabsURL();
		        	  this.activeName=this.$store.state.warning.activeName;
		        	}
	        	}
        		if(getTab==1){
        			this.activeName=this.$store.state.warning.activeName00;
		        	if(this.activeName == ''){
		        	  this.changeTabsURL();
		        	  this.activeName=this.$store.state.warning.activeName00;
		        	}
        		}
        		if(getTab==2){
        			this.activeName=this.$store.state.warning.activeName2;
		        	if(this.activeName == ''){
		        	  this.changeTabsURL();
		        	  this.activeName=this.$store.state.warning.activeName2;
		        	}
        		}
        	}else{
        		if(getTab==0){
        			this.activeName=this.$store.state.warning.activeName1;
		        	if(this.activeName == ''){
		        	  this.changeTabsURL();
		        	  this.activeName=this.$store.state.warning.activeName1;
		        	}
        		}
        		if(getTab==1){
        			this.activeName=this.$store.state.warning.activeName11;
		        	if(this.activeName == ''){
		        	  this.changeTabsURL();
		        	  this.activeName=this.$store.state.warning.activeName11;
		        	}
        		}
        		if(getTab==2){
        			this.activeName=this.$store.state.warning.activeName22;
		        	if(this.activeName == ''){
		        	  this.changeTabsURL();
		        	  this.activeName=this.$store.state.warning.activeName22;
		        	}
        		}
        	}
        },
        watch:{
            $route(){
                setTimeout(()=>{
                let url = window.location.href;
		        url = url.substring(url.lastIndexOf("="));
		        let getTab = url.charAt(1);
            	this.getURL()
                	if(this.today==1){
                		if(getTab==0){this.activeName=this.$store.state.warning.activeName;}
                		if(getTab==1){this.activeName=this.$store.state.warning.activeName00;}
                		if(getTab==2){this.activeName=this.$store.state.warning.activeName2;}
			        	
		        	}else{
		        		if(getTab==0){this.activeName=this.$store.state.warning.activeName1;}
		        		if(getTab==1){this.activeName=this.$store.state.warning.activeName11;}
		        		if(getTab==2){this.activeName=this.$store.state.warning.activeName22;}
		        	}
                },10)
            }
        },
        methods: {
		  	handleClick (tab, event) {
		  		let url = window.location.href;
		        url = url.substring(url.lastIndexOf("="));
		        let getTab = url.charAt(1);
		  		if(this.today==1){
		  			if(getTab==0){this.$store.commit(ACTIVE_NAME, { activeName: tab.name})}
		  			if(getTab==1){this.$store.commit(ACTIVE_NAME_FAKE, { activeName00: tab.name})}
		  			if(getTab==2){this.$store.commit(ACTIVE_NAME_RPT, { activeName2: tab.name})}
		  			
		  		}else{
		  			if(getTab==0){this.$store.commit(ACTIVE_NAME_H, { activeName1: tab.name})}
		  			if(getTab==1){this.$store.commit(ACTIVE_NAME_FAKE_H, { activeName11: tab.name})}
		  			if(getTab==2){this.$store.commit(ACTIVE_NAME_RPT_H, { activeName22: tab.name})}
		  		}
		    },
		    changeTabsURL(){
		    	let url = window.location.href;
		        url = url.substring(url.lastIndexOf("="));
		        let tab = url.charAt(1);
		        if(this.today==1){
		        	if(tab==1){
		        		this.$store.commit(ACTIVE_NAME_FAKE, { activeName00: '1'});
		        	}
		        	if(tab==2){
		        		this.$store.commit(ACTIVE_NAME_RPT, { activeName2: '2'});
		        	}
		        	if(tab==0){
		        		this.$store.commit(ACTIVE_NAME, { activeName: '0'});
		        	}
		        }else{
		        	if(tab==1){
		        		this.$store.commit(ACTIVE_NAME_FAKE_H, { activeName11: '1'});
		        	}
		        	if(tab==2){
		        		this.$store.commit(ACTIVE_NAME_RPT_H, { activeName22: '2'});
		        	}
		        	if(tab==0){
		        		this.$store.commit(ACTIVE_NAME_H, { activeName1: '0'});
		        	}
		        }
		    },
		    getURL(){
		    	let url = window.location.href;
		        url = url.substring(url.lastIndexOf("="));
		        this.tab = url.charAt(2);
		        if(this.tab==''){
		        	this.today=1
		        }else{
		        	this.today=0
		        }
		    }
        },
        updated(){},
        created () {},
        components: {
            warnlist0,
            warnlist1,
            warnlist2
        }
    }
</script>

<style lang="scss">
	#collectList{
		margin-top:20px;
		.el-table__empty-block{width: 100% !important;}
		.el-tabs__content{display: block !important;}
		.el-tabs__nav-scroll{padding-left: 20px !important;}
		.el-tabs__header{border-bottom: 1px solid rgba(217, 217, 217, 1)!important;padding-left: 20px !important;}
	}
</style>